package TestCases;

import java.util.Map;
import org.slf4j.LoggerFactory;
import com.beans.AdminUserBean;
import com.beans.CompanyBean;
import com.beans.ORGBean;
import coms.TestDateString;
import coms.process.AccountantCalendarProcess;
import coms.process.AddGroupProcess;
import coms.process.AddGroupWorkProcess;
import coms.process.LoginTest;
import frame.FrameWork;
import frame.InterTest;
import functions.ems_base_data.MdOu;
import functions.mams_rest.User;

/**
 * 共享会计池设置小组，工作范围，在岗不在岗，日历
 * @author CHENHAILIAN6
 *
 */
public class AccountingPoolConfigTestcase  extends BaseTestCase implements InterTest{
  private org.slf4j.Logger logger = LoggerFactory.getLogger(AccountingPoolConfigTestcase.class);
  String groupId;
  public String getGroupId() {
    return groupId;
  }

  public void setGroupId(String groupId) {
    this.groupId = groupId;
  }

  

   /* 入参:companyName,deptName,membersTasks
  * groupType(可不填，默认为0),membersTasks(可不填，默认为100)
  * categoryCode，categoryName
   * useFlay (可不填，默认为0),rateValue(可不填，默认为"")
  * */
  @Override
  public void run(Map<Object, Object> paramMap) {
    String baseUrl = (String) paramMap.get("baseUrl");
    if(baseUrl !=null) {
      FrameWork.setBaseUrl(baseUrl);
    }
      LoginTest loginTest = new LoginTest();
      loginTest.run(paramMap);
      
    String applyCompany = (String) paramMap.get("applyCompany");
    String companyCode = (String) paramMap.get("companyCode");
   /* if(companyName == null) {
      User user = new User();
      user.admin();
      AdminUserBean userBean = user.getUserBean();
      companyName = userBean.getCompanyDesc();
      companyCode = userBean.getCompany();
    }*/
    AddGroupProcess process = new AddGroupProcess();
    process.run(paramMap);
    
    String groupName = process.getGroupName();
    paramMap.put("groupName", groupName);
    System.out.println("groupName: " + groupName);
    ORGBean auditSelectOrg = process.getAuditSelectOrg();
    System.out.println("auditSelectOrg === " + auditSelectOrg.toString());
    ORGBean applyOrg =  (ORGBean) paramMap.get("applyOrg");

    paramMap.put("deptBean", applyOrg);
    logger.info("workGroup applyOrg param: " + applyOrg.toString());
    AddGroupWorkProcess groupWorkProcess = new AddGroupWorkProcess();
   
    MdOu ou = new MdOu();
    CompanyBean companyBean = ou.getCompanyByCompanyName(applyCompany);
    paramMap.put("companyBean", companyBean);
    groupWorkProcess.run(paramMap);
    groupId = groupWorkProcess.getGroupId();
    paramMap.put("workDate", TestDateString.today());
    paramMap.put("workFlag", "1");
    AccountantCalendarProcess calendar = new AccountantCalendarProcess();
    calendar.run(paramMap);
  }

  @Override
  public boolean getStatus() {
    // TODO Auto-generated method stub
    return false;
  }

  @Override
  public String getRemark() {
    // TODO Auto-generated method stub
    return null;
  }

}
